home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_06
/
gotwals
/
sqrt.cpp
< prev
next >
Wrap
Text File
|
1994-04-01
|
452b
|
16 lines
====================== Listing 7 ======================
/* Compute the greatest integer less than or equal
to the square root of lint. From "Factorization
and Primality Testing", Bressoud
------------------------------------------------ */
LargeInt sqrt(const LargeInt& lint) {
LargeInt a = lint;
LargeInt b = (lint + one) / two;
while (b < a) {
a = b;
b = (a * a + lint) / (two * a);
}
return a;
}